package com.junzhiit.nengji.shop.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.bainaeco.framework.util.AssertUtil;
import com.junzhiit.nengji.shop.service.FavoriteShopService;
import com.junzhiit.nengji.shop.web.vo.ResultVO;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/favorite/shop")
public class FavoriteShopController extends BaseController {
	
	@Autowired
	private FavoriteShopService favoriteShopService;
	
	@ApiOperation(value = "添加收藏商铺")
	@RequestMapping(method = RequestMethod.POST)
	public ResultVO add(String shopId,String userId){
		AssertUtil.notBlank(userId, "userId is required.");
		return favoriteShopService.add(shopId,userId);
	}
	
	@ApiOperation(value = "取消收藏商铺")
	@RequestMapping(method = RequestMethod.PUT)
	public ResultVO delete(String userId,String favoriteShopId){
		AssertUtil.notBlank(userId, "userId is required.");
		AssertUtil.notBlank(favoriteShopId, "favoriteShopId is required.");
		return favoriteShopService.delete(userId, favoriteShopId);
	}
	
	@ApiOperation(value = "查询收藏商铺列表")
	@RequestMapping(method = RequestMethod.GET)
	public ResultVO get(Integer pageNumber,Integer maxPageRow,String userId,String shopId){
		AssertUtil.notNull(pageNumber, "pageNumber is required.");
		AssertUtil.notNull(maxPageRow, "maxPageRow is required.");
		AssertUtil.notBlank(userId, "userId is required.");
		return favoriteShopService.getFavoriteShop(pageNumber,maxPageRow,userId,shopId);
	}
}
